<?php
// module/Album/view/album/album/add.phtml:

$title = 'Add new album';
$this->headTitle($title);
?>
<h1><?php echo $this->escapeHtml($title); ?></h1>
<?php
$form = $this->form;
$form->setAttribute('action', $this->url('album', array('action' => 'add')));
$form->prepare();
echo $this->form()->openTag($form);

?>
<div class="control-group" style="width:300px;">
    <?php echo $this->formLabel($form->get('title')->setLabelAttributes(array('class'=>'control-label'))); ?>
    <div class="controls">
        <?php echo $this->formInput($form->get('title')); ?>
    </div>
     <div class="error">
    <?php echo $this->formElementErrors($form->get('title')); ?>
    </div>
</div>
<div class="control-group">
    <?php echo $this->formLabel($form->get('artist')->setLabelAttributes(array('class'=>'control-label'))); ?>
    <div class="controls">
        <?php echo $this->formInput($form->get('artist')); ?>
    </div>
     <div class="error">
    <?php echo $this->formElementErrors($form->get('artist')); ?>
    </div>
</div>

<div class="control-group">
    <?php echo $this->formLabel($form->get('category_id')->setLabelAttributes(array('class'=>'control-label'))); ?>
    <div class="controls">
        <?php echo $this->formSelect($form->get('category_id')); ?>
    </div>
     <div class="error">
    <?php echo $this->formElementErrors($form->get('category_id')); ?>
    </div>
</div>





<div class="control-group">
    <?php //echo $this->formLabel($form->get('submit')->setLabelAttributes(array('class'=>'control-label'))); ?>
    <div class="controls">
        <?php echo $this->formInput($form->get('submit')); ?>
    </div>

</div>
<?php
echo $this->form()->closeTag();

?>

<script type="text/javascript">
  $(function(){


    function getCat(){
      var URL = '/album/ajax-get-cat';
      $.ajax({
        url:URL,
        data:{},
        dataType:'json',
        type:'POST',
        beforeSend:function(){  },

        success:function(data){
          var cat = '<option>-SELECT-</option>';
          $.each(data, function(i,message) {
            cat += '<option value="'+message.id+'">'+message.name+'</option>';

          })

          $('#cat_sel_id').html(cat);
        },
        complete:function(){

        },
        error: function(xhr,status,error) { alert('Error: ' + status) ; }
      });
    }


      getCat();

  });
</script>
